package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-08 16:03
 * @Modified By:
 */
public class CheckPerfectNumber_507 {
    public static void main(String[] args) {

    }

    public boolean checkPerfectNumber(int num) {
        if (num < 0) {
            return false;
        }
        int sum = 0;
        for (int i = 1; i * i <= num; i++) {
            if (num % i == 0) {
                sum += i;
                if (i * i != num) {
                    sum += num / i;
                }
            }
        }
        return sum - num == num;
    }
}
